{include /common/header}
<form action="{:\mylib\Route::buildUrl('/admin/channel/add')}" method="POST">
    <fieldset>
        <legend>新增栏目</legend>

        {php}function _show($channels, $pid=0, $level=1){{/php}
            {foreach $channels as $v}
            {if $v['pid'] == $pid && $v['type'] == 'channel'}
                <option value="{$v.id}">{:str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;', $level)}├&nbsp;{$v.title}</option>
                {:_show($channels, $v['id'], $level+1)}
            {/if}
            {/foreach}
        {php}}{/php}
        <div class="form-group">
            <label>父栏目</label>
            <select class="form-control" name="pid" required>
                <option value="0" selected>顶级栏目</option>
                {:_show($channels)}
            </select>
        </div>

        <div class="form-group">
            <label>目录路径</label>
            <input type="text" class="form-control" name="path" value="" required>
            <span class="help-block">'/'开头</span>
        </div>

        <div class="form-group">
            <label>标题</label>
            <input type="text" class="form-control" name="title" value="" required>
        </div>

        <div class="form-group">
            <label>关键词</label>
            <input type="text" class="form-control" name="keywords" value="">
        </div>

        <div class="form-group">
            <label>简介</label>
            <textarea class="form-control" name="description" cols="80" rows="3"></textarea>
        </div>

        {if $type == 'channel'}
            <div class="form-group">
                <label>封面模板</label>
                <input type="text" class="form-control" name="tpl" value="">
            </div>

            <div class="form-group">
                <label>跳转地址</label>
                <input type="text" class="form-control" name="jump" value="">
            </div>
        {/if}

        {if $type == 'list'}
            <div class="form-group">
                <label>栏目模板</label>
                <input type="text" class="form-control" name="tpl" value="">
            </div>

            <div class="form-group">
                <label>内容默认模板</label>
                <input type="text" class="form-control" name="tpl_detail" value="">
            </div>

            <div class="form-group">
                <label>模型扩展</label>
                <select class="form-control" name="model_id" required>
                    <option value="0">不扩展</option>
                    {foreach $models as $v}
                    <option value="{$v.id}">{$v.title}</option>
                    {/foreach}
                </select>
                <span class="help-block"><a href="{:\mylib\Route::buildUrl('/admin/model/index')}" target="main">模型管理</a></span>
            </div>

            <div class="form-group">
                <label>是否允许投稿</label>
                <select class="form-control" name="contribute" required>
                    <option value="0">不允许</option>
                    <option value="1">允许</option>
                </select>
            </div>

            <div class="form-group">
                <label>分页大小</label>
                <input type="number" class="form-control" name="pagenum" value="20">
            </div>
        {/if}

        {if $type == 'page'}
            <div class="form-group">
                <label>单页模板</label>
                <input type="text" class="form-control" name="tpl" value="">
            </div>

            <div class="form-group">
                <label>内容</label>
                <textarea name="body" rows="6" class="form-control xheditor {urlType:'abs',html5Upload:true,upMultiple:true,upLinkUrl:'{:\mylib\Route::buildUrl('/admin/api/xhupload')}',upLinkExt:'zip,rar,txt',upImgUrl:'{:\mylib\Route::buildUrl('/admin/api/xhupload')}',upImgExt:'jpg,jpeg,gif,png',upFlashUrl:'{:\mylib\Route::buildUrl('/admin/api/xhupload')}',upFlashExt:'swf',upMediaUrl:'{:\mylib\Route::buildUrl('/admin/api/xhupload')}',upMediaExt:'avi'}"></textarea>
            </div>
        {/if}

        {if $type == 'jump'}
            <div class="form-group">
                <label>跳转地址</label>
                <input type="text" class="form-control" name="jump" value="">
            </div>
        {/if}

        <div class="form-group">
            <label>打开方式</label>
            <select class="form-control" name="target" required>
                <option value="_self" selected>当前窗口</option>
                <option value="_blank">新窗口</option>
            </select>
        </div>

        <div class="form-group">
            <label>导航显示</label>
            <select class="form-control" name="nav" required>
                <option value="1" selected>显示</option>
                <option value="0">不显示</option>
            </select>
        </div>

        <div class="form-group">
            <label>是否发布</label>
            <select class="form-control" name="status" required>
                <option value="1" selected>发布</option>
                <option value="0">不发布</option>
            </select>
        </div>

        <div class="form-group">
            <label>排序</label>
            <input type="number" class="form-control" name="weight" value="50">
        </div>

        <input type="hidden" name="type" value="{$type}">
        <button type="submit" class="btn btn-primary">提交</button>
    </fieldset>
</form>
{include /common/footer}